package com.fz.controller;

import cn.hutool.core.date.DateUtil;
import com.fz.entity.Goods;
import com.fz.service.GoodsService;
import com.fz.vo.ResultVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 商品 前端控制器
 * </p>
 *
 * @author yuelli
 * @since 2024-08-13
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Resource
    GoodsService goodsService;
    @GetMapping("/list")
    ResultVo<List<Goods>> list() {
        return ResultVo.success(goodsService.list());
    }

    @PostMapping("/add")
    ResultVo<Boolean> add(Goods goods) {
        goods.setCreateTime(DateUtil.now());
        return ResultVo.success(goodsService.save(goods));
    }

}
